<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.fick.hibernate.model.*"%>
<%@ page import="com.fick.hibernate.dao.*"%>
<%@ include file="../tld/tlds.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>在线调查</title>
<link href="images/jiahao.css" rel="stylesheet" type="text/css">

		<link href="css/css.css" rel="stylesheet" type="text/css" />
		<script language="JavaScript" src="js/meihuaxue.js"></script>
		<script language="javaScript" src="js/prototype.js"></script>
		<script type="text/javascript" src="js/submit.js"></script>
		
</head>

<body>
<%
	VoteDAO dao=new VoteDAO();
Vote vote;
		    //当前页面
			int currPage = 1;
			//总的页数
			int totalPage = 1;
			//一个页面可显示的记录数
			int pageSize = 10;
			//总共有的记录数
			int totalCount = 1;
			List  li = new ArrayList();
			//li = linkDao.findAll();
			//得到总的记录数
			totalCount = dao.count(Vote.class,"");
			//得到总的页数
			if(totalCount%pageSize==0){
				totalPage = totalCount/pageSize;
			}else{
				totalPage = totalCount/pageSize+1;
			}
			//判断是否是传过来页数
			if(request.getParameter("currPage") != null){
			   currPage = Integer.parseInt(request.getParameter("currPage"));
			   if(currPage<1){
			     currPage=1;
			    }
			   if(currPage >totalPage){
			     currPage = totalPage;
			   }
			} 
			//得到记录数
			
			  List li2 = dao.findPageBySql(Vote.class,currPage,pageSize,"order by investId desc");
		 %>

<table width="100%"  height="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="100%" align="center" valign="top" background="images/main_bj.gif" bgcolor="#FBFCFD"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="23" align="left" valign="middle" background="images/main_top.gif"><table border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="20" height="23">&nbsp;</td>
            <td width="400" height="23" align="left" valign="middle" class="ts_lmdh2">在线调查管理 </td>
          </tr>
        </table></td>
      </tr>
    </table>
      <table width="98%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="20" align="left"><input type="button" value="添加在线调查" onclick="window.location.href='addVote.jsp'"></td>
        </tr>
      </table>
      <table width="98%" border="0" cellpadding="0" cellspacing="1" bgcolor="#D7DFE1">
        <tr>
		 <td width="6%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">选择</td>
          <td width="37%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">调查名</td>
		 <td width="6%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">是否多选</td>
          <td width="20%" height="25" align="center" valign="middle" background="images/main_t_bj.gif" bgcolor="#FFFFFF" class="ts_lmdh">操作</td>
        
        </tr>
       
	   <%
		for(int i = 0 ; i < li2.size(); i++){
			vote = (Vote)li2.get(i);
										      
	 %>
	    <tr>
		<td width="6%" height="25" align="center" valign="middle" bgcolor="#FFFFFF">
		<input type="checkbox" name="MyCheckBox" id="MyCheckBox"
													value="<%=vote.getInvestId() %>" />
		</td>
          <td width="37%" height="25" align="left" valign="middle" bgcolor="#FFFFFF" style="padding-left:7px">
		  <%=vote.getQuestion()%>
		  </td>
  			<td width="10%" height="25" align="center" valign="middle" bgcolor="#FFFFFF">
			<%= vote.getIsCheckbox()==1?"是":"否" %>
			</td>
  			<td width="10%" height="25" align="center" valign="middle" bgcolor="#FFFFFF">
  			<a href="voteinfo.jsp?voteid=<%=vote.getInvestId() %>">选项</a>
			<a href="addVote.jsp?id=<%=vote.getInvestId() %>">修改</a>&nbsp;
			<a href="<%=request.getContextPath()%>/admin/vote.do?method=delById&id=<%=vote.getInvestId() %>">删除</a>
			</td>
        </tr>
      <%
	  }
	  %>
	  
	  <tr>
		<td colspan="4" align="left">
		<input type="button" name="selectAlls" id="selectAlls" value="全选" onclick="return selectAll()" />
		<input type="button" name="noSelectAll" id="noSelectAll" value="反选" onclick="return selectOthers();" />
		<input type="button" name="cancelSelects" id="cancelSelects" value="取消选择" onclick="return cancelSelect();" />
		<input type="button" name="delAlls" id="delAlls" value="删除所选" onclick="return delAll('/admin/vote.do?method=delAll&str=');"/>
		</td>
	</tr>
	  
	  </table>
	  
	  
	  
	  
	  
      <table width="98%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="45" align="center" valign="middle">
		  共有［<%=totalCount %>］页 当前是第［<%=currPage %>/<%=totalPage %>］页 [
												<a href="vote.jsp?currPage=1" class="page">首页</a>][
												<a href="vote.jsp?currPage=<%=currPage-1 %>"
													class="page">上一页</a>][
												<a href="vote.jsp?currPage=<%=currPage+1 %>"
													class="page">下一页</a>][
												<a href="vote.jsp?currPage=<%=totalPage %>"
													class="page">尾页</a>]
		  到第
		  <select onchange="gopage(this)">
		  <%
				for(int i = 0;i<totalPage ; i++)
				{
					out.print("<option value='vote.jsp?currPage="+(i+1)+"'>"+(i+1)+"</option>");
				}
			%>
		  </select>	
          页</td>
        </tr>
      </table></td>
  </tr>
</table>
</body>
</html>
<script language="javascript">
 function gopage(selected)
 {
 	window.open(selected.value,"_self");
 }
 </script>